<?php
/**
 * @name DashboardController.php
 * @copyright (c) 2011
 * @author Arsene Tochemey GANDOTE<arsene.gandote@yahoo.com>
 */
class DashboardController extends AppController{
	# Controller name
	var $name = 'Dashboard';
	# set the model to use
	var $uses = array('User');
	# Set the layout to use
	var $layout = 'dashboard_layout';
        # Helpers and components
	
	# Controllers Actions
	/**
	 * This function checks the authenticity of the user.
	 * @name beforeFilter
	 * @param void
	 * @return void
	 * @access public
	 * */
	function beforeFilter(){
        parent::setUpGlobalConfig();  
		# check whether the user is logged on to the system or not.
		if(!$this->Session->check('userSessionData')){
			# disallow the user to run the controller actions and ask him/her to login.
			$this->redirect('/');
		}
	}
	
	/**
	 * This is a kind of home page of the controller Dashboard.
	 * @name index
	 * @param void
	 * @var mixed $loggedUser array containing the logged user session data.
	 * @return void
	 * @access public
	 * */
	function index(){
		# Read the logged user data
		$loggedUser = $this->Session->read('userSessionData');
		# retrieve the user data and related data and set it as returned value
		$this->set('userData', $this->User->getUserById($loggedUser['id']));
	}
}
?>